import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Toolkit;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.SwingConstants;
//import org.eclipse.wb.swing.FocusTraversalOnArray;
import java.awt.Component;
import javax.swing.JLayeredPane;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;


public class TitleScreen extends JPanel implements KeyListener {

	//private JPanel contentPane;
	static JLabel label_1 = new JLabel("");
	
	/**
	 * Launch the application.
	 */
	/*public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					final TitleScreen frame = new TitleScreen();
					
					//frame.setLocationRelativeTo(null);
					//frame.setVisible(true);
					
//					for (int i = 0; i < 100; i++)
//					{
//						label_1.setVisible(true);
//						Thread.sleep(1000);
//						label_1.setVisible(false);
//						Thread.sleep(1000);
//						
//					}
					
					frame.addKeyListener(new KeyAdapter()
					{
						@Override
						public void keyPressed(KeyEvent arg0)
						{
							int id = arg0.getKeyCode();
								if (id == KeyEvent.VK_ENTER)
								{
									//MainMenu frame2 = new MainMenu();
									//frame.setVisible(false);
									//frame2.setVisible(true);
								}
						}
					});

					
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	*/

	/**
	 * Create the frame.
	 */
	public TitleScreen() {

	
		this.setLayout(null);
		this.setBackground(new Color(155, 80, 184));
		this.setBorder(new EmptyBorder(5, 5, 5, 5));

		
		JLabel lblNewLabel = new JLabel("");
		lblNewLabel.setBounds(0, 0, 794, 567);
		lblNewLabel.setBackground(new Color(155, 80, 184));
		lblNewLabel.setIcon(new ImageIcon("C:\\Users\\Deposition\\workspace\\TypingTron\\titlescreengoodresizenotrans.png"));
		this.add(lblNewLabel);
		
		JPanel panel = new JPanel();
		panel.setBounds(0, 0, 794, 110);
		panel.setBackground(new Color(200, 191, 231));
		this.add(panel);
		
		JLayeredPane layeredPane = new JLayeredPane();
		layeredPane.setBounds(124, 445, 600, 94);
		this.add(layeredPane);
		
		JLabel label_1 = new JLabel("");
		label_1.setBounds(0, 0, 600, 83);
		layeredPane.add(label_1);
		label_1.setIcon(new ImageIcon("C:\\Users\\Deposition\\workspace\\TypingTron\\Dialog.png"));
		//contentPane.setFocusTraversalPolicy(new FocusTraversalOnArray(new Component[]{lblNewLabel, panel, label_1}));
		
		this.setFocusable(true);

		this.addKeyListener(new KeyAdapter() {
			@Override
			public void keyPressed(KeyEvent arg0) {

				int id = arg0.getKeyCode();
				if (id == KeyEvent.VK_ENTER) {
					// gets parent panel
					JPanel parent = (JPanel) javax.swing.SwingUtilities.getAncestorOfClass(JPanel.class,TitleScreen.this);
				
					// Show Login Screen
					CardLayout layout = (CardLayout)(parent.getLayout());
					layout.show(parent, "login");
				}

			}

		});
	}

	@Override
	public void keyPressed(KeyEvent arg0) {
		int id = arg0.getKeyCode();
		if (id == KeyEvent.VK_ENTER) {
		// gets parent panel
		JPanel parent = (JPanel) javax.swing.SwingUtilities.getAncestorOfClass(JPanel.class,TitleScreen.this);
		
		// Show Login Screen
		CardLayout layout = (CardLayout)(parent.getLayout());
		layout.show(parent, "login");
		}

	}

	@Override
	public void keyReleased(KeyEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyTyped(KeyEvent arg0) {
		// TODO Auto-generated method stub
		
	}
}
